package com.aaa.gs;

import com.aaa.gs.config.RibbonLoadBalanceConfig;
import org.mybatis.spring.annotation.MapperScan;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.cloud.client.discovery.EnableDiscoveryClient;
import org.springframework.cloud.client.loadbalancer.LoadBalanced;
import org.springframework.cloud.netflix.ribbon.RibbonClient;
import org.springframework.context.annotation.Bean;
import org.springframework.transaction.annotation.EnableTransactionManagement;
import org.springframework.web.client.RestTemplate;
import springfox.documentation.swagger2.annotations.EnableSwagger2;

/**
 * @ fileName:OrderAServerApp
 * @ description:
 * @ author:zhz
 * @ createTime:2023/6/6 16:34
 * @ version:1.0.0
 */
@SpringBootApplication
@MapperScan("com.aaa.gs.dao")
@EnableSwagger2
@EnableDiscoveryClient  //开启发现客户端    注册中心客户端注解
@RibbonClient(name = "GoodsServerRibbon",configuration = RibbonLoadBalanceConfig.class)
@EnableTransactionManagement
public class GoodsServerApp {
    public static void main(String[] args) {
        SpringApplication.run(GoodsServerApp.class, args);
    }

    /**
     * 配置RestTemplate 方便后面服务进行调用
     * @return
     */
    @Bean
    @LoadBalanced //远程调用时，使用负载均衡  使用在RibbonClient注解configuration配置的方式
    public RestTemplate restTemplate(){
        return new RestTemplate();
    }

}
